<?php
 
/*
 * Following code will update a product information
 * A product is identified by product id (pid)
 */
 
// array for JSON response
$response = array();
 
// check for required fields
if (isset($_POST['user_id_zing']) && isset($_POST['user_name_zing']) && isset($_POST['user_avatar_zing'])&& isset($_POST['user_display_name'])) {
 
    $user_id_zing = $_POST['user_id_zing'];
    $user_name_zing = $_POST['user_name_zing'];
    $user_display_name = $_POST['user_display_name'];
    $user_avatar_zing = $_POST['user_avatar_zing'];
 
    // include db connect class
    require_once __DIR__ . '/db_connect.php';
 
    // connecting to db
    $db = new DB_CONNECT();
 
    // mysql update row with matched pid
    $result = mysql_query("UPDATE user SET user_display_name = '$user_display_name', user_name_zing = '$user_name_zing', user_avatar_zing = '$user_avatar_zing' WHERE user_id_zing = $user_id_zing");
 
    // check if row inserted or not
    if ($result) {
        // successfully updated
        $response["success"] = 1;
        $response["message"] = "Successfully updated.";
 
        // echoing JSON response
        echo json_encode($response);
    } else {
 
    }
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
 
    // echoing JSON response
    echo json_encode($response);
}
?>